Problem Note 31754: PROC FONTREG generates "Invalid file type" error
When PROC FONTREG is used to register fonts using the FONTPATH, TRUETYPE, or TYPE1 statement, the following error is generated if a font in the specified directory has an extension longer than eight characters:
ERROR: Invalid file type.
To circumvent the problem, use the FONTFILE statement to only register fonts with the .TTF extension. The sample code shows a macro which loops through the Windows system fonts directory, and loads each with an individual FONTFILE statement.
Operating System and Release Information
SAS System | Base SAS | Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M0 | 9.2 TS2M0 |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M0 | 9.2 TS2M0 |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M0 | 9.2 TS2M0 |
Microsoft Windows 2000 Advanced Server | 9.1 TS1M0 | |
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M0 | |
Microsoft Windows 2000 Server | 9.1 TS1M0 | |
Microsoft Windows 2000 Professional | 9.1 TS1M0 | |
Microsoft Windows NT Workstation | 9.1 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M0 | 9.2 TS2M0 |
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M0 | 9.2 TS2M0 |
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M0 | 9.2 TS2M0 |
Microsoft Windows XP Professional | 9.1 TS1M0 | 9.2 TS2M0 |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
This code provides a workaround for the problem. If fonts in the system fonts directory have an extension longer than eight characters, a FONTPATH, TRUETYPE, or TYPE1 statement will generate an error. This code generates an individual FONTFILE statement for each font with a .TTF extension.
%macro drive(dir,ext);
%let filrf=mydir;
/* Assigns the fileref of mydir to the directory and opens the directory */
%let rc=%sysfunc(filename(filrf,&dir));
%let did=%sysfunc(dopen(&filrf));
/* Returns the number of members in the directory */
%let memcnt=%sysfunc(dnum(&did));
proc fontreg;
fontfile
/* Loops through entire directory */
%do i = 1 %to 5;
/* Returns the extension from each file */
%let name=%qscan(%qsysfunc(dread(&did,&i)),-1,.);
/* Checks to see if file contains an extension */
%if %qupcase(%qsysfunc(dread(&did,&i))) ne %qupcase(&ext) %then %do;
/* Checks to see if the extension matches the parameter value */
/* If condition is true prints the full name to the log */
%if (%superq(ext) ne and %qupcase(&name) = %qupcase(&ext)) or
(%superq(ext) = and %superq(name) ne) %then %do;
"&dir.\%qsysfunc(dread(&did,&i))"
%end;
%end;
%end;;
/* Closes the directory */
%let rc=%sysfunc(dclose(&did));
run;
%mend drive;
/* First parameter is the directory of where your files are stored. */
/* Second parameter is the extension you are looking for. */
/* Leave second paramater blank if you want a list of all the files. */
options mprint;
%drive(%sysget(systemroot)\fonts,ttf)
If a FONTPATH, TRUETYPE, or TYPE1 statement is used with PROC FONTREG, an "Invalid File Type" error can be generated.
Type: | Problem Note |
Priority: | medium |
Date Modified: | 2008-04-14 09:50:11 |
Date Created: | 2008-04-10 09:03:53 |